//
//  YLDViewController.m
//  CallTrace
//
//  Created by yilongdong on 09/07/2022.
//  Copyright (c) 2022 yilongdong. All rights reserved.
//

#import "YLDViewController.h"

@interface YLDViewController ()

@end

@implementation YLDViewController

- (void)testLevelThree {
    NSLog(@"entry %s", __FUNCTION__);
    __unused NSException *ex = [[NSException alloc]initWithName:@"test_hook_ex" reason:@"test_ex" userInfo:nil];
    @throw(ex);
    NSLog(@"exit %s", __FUNCTION__);
}

- (void)testLevelTwo {
    NSLog(@"entry %s", __FUNCTION__);
    [self testLevelThree];
    NSLog(@"exit %s", __FUNCTION__);
}

- (void)testLevelOne {
    NSLog(@"entry %s", __FUNCTION__);
    [self testLevelTwo];
    NSLog(@"exit %s", __FUNCTION__);
}

- (void)viewDidLoad
{
    NSLog(@"entry %s", __FUNCTION__);
    [super viewDidLoad];
    
    @try {
        [self testLevelOne];
    }
    @catch(NSException *exception) {
        NSLog(@"捕获到了异常");
        NSLog(@"ex.name = %@", exception.name);
    }
    @finally {
        NSLog(@"finally");
    }
	// Do any additional setup after loading the view, typically from a nib.
    NSLog(@"exit %s", __FUNCTION__);
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
